The Purpose of This Independent Project

Consider Your Lifestyle

Consider Your Expectations

Character Traits

Breed Groups

Load the Libraries

library(plotly)
library(here)
library(tidyverse)
library(ggplot2)
library(dplyr)
library(magick)

Read in the Data

Breed_Traits <- read_csv(here("Data","Breed Traits.csv")) # Load first data set

View(Breed_Traits)


AKC_Breed_Info <- read_csv(here("Data","AKC Breed Info.csv")) # Load second data set 

View(AKC_Breed_Info)

Pivot Data Long

long <- Breed_Traits %>%
 pivot_longer(cols = c(`Affectionate With Family`,`Good With Young Children`, `Good With Other Dogs`, `Shedding Level`, `Coat Grooming Frequency`, `Drooling Level`, `Openness To Strangers`, `Playfulness Level`, `Watchdog/Protective Nature`, `Adaptability Level`, `Trainability Level`, `Energy Level`, `Barking Level`, `Mental Stimulation Needs`), # variables in the new column
              names_to = 'Traits', # new name of the column
              values_to = 'Values') # name of the column 
View(long)

Create Bar Plot: Character traits measured by Breed Group

Traits_long <- long %>% # graph with this data 
  plot_ly(x = ~ `Breed Group`, 
          y = ~ Values,
          color = ~ Traits,
          type = "bar", # bar graph 
          marker = list(color = rainbow(nrow(long)))) %>% # bar graph is colored by rainbow
  layout(title = 'Breed vs. Traits', # add a title 
         xanchor = 'center', # center the title 
          yanchor = 'top',
         font = list(color = "darkorchid"), # change title color 
       plot_bgcolor = "white", # made background white
       paper_bgcolor = "lavender", # paper background color
       xaxis = list(title = 'Breed Group', # label x axis
                    tickangle = -45, # angle the x axis 
                    color = "darkorchid", # color x axis
                      size = 15),# make the x axis smaller 
       yaxis = list(title = 'Rank', # label y axis 
                    color = "darkorchid"), # color of y axis title 
       legend = list(title = list(text = '<b> Traits </b>', # rename legend 
                        font = list(color = "darkorchid"), # change legend color 
                                  xanchor = 'center', # center the legend
                                  yanchor = 'top')))



Traits_long

4 categories picked

Filter Data To Visualize Coat Length

coat_filtered <- Breed_Traits %>%
  filter(`Breed Group` %in% c("Hound","Sporting")) %>% # filter out breed group
  filter(`Coat Type` %in% c("Smooth","Double")) %>%# filter out coat preference
  filter(`Affectionate With Family` >= 3)%>%
  filter(`Good With Other Dogs` >= 3) %>%
  filter(`Trainability Level` >=3) %>%
  filter(`Adaptability Level` >=3) %>%
  filter(`Coat Length` == "Short")
  
  
  
  
View(coat_filtered)

Make filter into table

table <- coat_filtered %>%
plot_ly(
  type = 'table',
  columnorder = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19),
  columnwidth = c(80),
  header = list(
    values = c("<b>Breed</b>",names(coat_filtered)),
    align = c('left',rep('center', ncol(coat_filtered))),
    line = list(width = 1, color = 'black'),
    fill = list(color = 'rgb(235,100,230)'),
    font = list(family = "Arial", size = 14, color = "white")
  ),
  cells = list(
    values = rbind(
      rownames(coat_filtered), 
      t(as.matrix(unname(coat_filtered)))
),
align = c('left', rep('center', ncol(coat_filtered))),
    line = list(color = "black", width = 1),
    fill = list(color = c('rgb(235, 193, 238)', 'rgba(228, 222, 249, 0.65)')),
    font = list(family = "Arial", size = 12, color = c("black"))
))

table

Scatter Plot: Coat Type for Certain Breeds

coat <- coat_filtered  %>% # use above filtered data
plot_ly(x = ~ `Coat Type`,
          y = ~ `Breed Group`,
          type = "scatter", # type of plot 
        mode = "markers",
        color = ~ Breed, # color by 
        colors = "Paired", # color pattern
        size = 20, # size of dots
        alpha = 0.5) %>% # transparency 
layout(title = 'Breed vs. Coat', # title 
         font = list(color = "navy"), # title color 
       plot_bgcolor = "white", # plot color 
       paper_bgcolor = "lightcyan", # background color 
       xaxis = list(title = 'Breed Group', # x axis title 
                    tickangle = -45, # angle x axis 
                    color = "navy"), # color x axis 
       yaxis = list(title = 'Rank', # title y axis 
                    color = "navy"), # color y axis 
       legend = list(title = list(text = '<b> Traits </b>', # title of legend
                                  font = list(color = "navy"),
                                  xanchor = 'center', # center title 
                                  yanchor = 'top')))
          
 coat # View plot 

weight range she chose

Filter Data To Visualize Weight

weight_f <- AKC_Breed_Info %>%
  drop_na() %>%
  filter(Breed %in% c("Whippet","Vizsla","Rhodesian Ridgeback","Labrador Retriever","German Shorthaired Pointer","Pharaoh Hound","Harrier","English Foxhound","Black And Tan Coonhound","Basset Hound","Beagle","Dachshund","Brittany","Weimarener","Bloodhound","Whippet","Basenji","Pointer","Greyhound","Redbone Coonhound")) %>% # filter data to be universal 
  filter(weight_low_lbs >= 45) %>% # look at weights greater than 45 lbs
  filter(weight_high_lbs <= 100) # weight less than 100 lbs
  
  

View(weight_f)

Scatter Plot: Weight for Certain Breeds

weight <- weight_f %>% # plot filtered data 
  plot_ly(x = ~ weight_low_lbs,
          y = ~weight_high_lbs,
          type = "scatter", # type of data
          mode = "markers",
          color = ~Breed, # color by
          colors = "Paired", # color pattern
          size = 22, # size of dot
          alpha = 1) %>%
layout(title = 'Breed vs. Weight', # title of plot
         font = list(color = "navy"), # title color 
       plot_bgcolor = "white",# plot color 
       paper_bgcolor = "lightcyan", # background color 
       xaxis = list(title = 'Low Weight Range', # x axis title 
                    tickangle = -45, # angle x axis 
                    color = "navy"), # color x axis
       yaxis = list(title = 'High Weight Range', # y axis title 
                    color = "navy"), # y axis color 
       legend = list(title = list(text = '<b> Breed </b>', # legend title 
                                  font = list(color = "navy"), # legend color 
                                  xanchor = 'center', # center title 
                                  yanchor = 'top')))

weight

Filter Data For 4 Categoires

trait_filter <- long %>%
  filter(Breed %in% c("Black and Tan Coonhounds","English Foxhounds","Pointers (German Shorthaired)","Greyhounds","Retrievers (Labrador)","Pharaoh Hounds","Redbone Coonhounds","Rhodesian Ridgebacks","Vizslas")) %>%
  filter(Traits %in% c("Trainability Level","Adaptability Level","Good With Other Dogs","Affectionate With Family"))

View(trait_filter)

Bar Plot: Final Filtered Breeds by Adaptability and Trainability

final <- trait_filter %>% # data used
  plot_ly(x = ~ Traits,
          y = ~Values,
          type = "bar", # type of graph 
          mode = "markers",
          color = ~Breed, # color by
          colors = "Dark2") %>% # color pattern
  layout(title = 'Vizsla vs. Greyhounds', # plot title
         font = list(color = "darkred"), # title color 
       plot_bgcolor = "bisque", # color of plot
       paper_bgcolor = "bisque", # color of background
       xaxis = list(title = 'Traits', # x axis title 
                    tickangle = -45, # angle x axis 
                    color = "darkred"), # x axis color
       yaxis = list(title = 'Rank',# y axis title
                    color = "darkred"), # y axis color
       legend = list(title = list(text = '<b> Breed </b>', # legend title
              font = list(color = "darkred"), # legend color
                      xanchor = 'center', # title centered 
                      yanchor = 'top')))


final

Image of The Winner

Vizsla <- image_read("https://images.ctfassets.net/m5ehn3s5t7ec/wp-image-198422/0e0fe308ed17ab3af5f3c8f2db288667/Vizsla-Dog-Breed-Information.jpg") # read in image

image_border(Vizsla, color = "peachpuff", 
             geometry = "8x10") %>% # Add a border
image_annotate("Vizsla", font = 'Palatino',
               size = 50, 
               gravity = "southwest",
               color = "black", 
               boxcolor = "peachpuff") # add text box